package com.twu.bibilioteca;

/**
 * Created by IntelliJ IDEA.
 * User: dixithk
 * Date: 6/18/14
 * Time: 2:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class CheckOutBook implements MenuOperations {
   
    UserInterface ui = new UserInterfaceApp();
    Library lib = new Library();

    public CheckOutBook(UserInterface Ui , Library lib)
    {
        this.ui = Ui;
        this.lib = lib;
        
    }
    @Override
    public Result action() {



        Book BookNeedToBeCheckedOut =  lib.GiveBookObjectFromTitle(ui.takeInputFromUserForCheckOut());
        if(BookNeedToBeCheckedOut!=null && (!lib.isAvailableForCheckOut(BookNeedToBeCheckedOut)))
        {
                BookNeedToBeCheckedOut.markAsCheckedOut();

                return  new Result("Thank you Enjoy the book " , true);




        }
        else
        {
            return new Result("That book is not available." ,false);
        }

         //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public String getName() {
        return "check out a book";  //To change body of implemented methods use File | Settings | File Templates.
    }
}
